<!DOCTYPE html>
<html lang="en">
  <head>
    <title>HTMLifier</title>
    <meta charset="UTF-8" />
    <meta
      name="description"
      content="Converts a Scratch project to HTML/JavaScript"
    />
    <meta
      property="og:image"
      content="https://sheeptester.github.io/img/htmlifier-smaller.png"
    />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- no-offline -->
    <link rel="stylesheet" type="text/css" href="../../sheep3.css" />
    <script src="../../sheep3.js" charset="utf-8"></script>
    <!-- /no-offline -->
    <link
      href="https://fonts.googleapis.com/css2?family=Exo:wght@500&family=Roboto:wght@300&display=swap"
      rel="stylesheet"
    />
    <link rel="stylesheet" href="./main.css" />
    <script type="text/javascript">
      window.errors = []
      if (window.addEventListener) {
        window.addEventListener(
          'error',
          function (e) {
            if (e.message) {
              if (e.error && e.error.stack) {
                if (e.message.indexOf('Uncaught SyntaxError') === 0) {
                  window.errors.push(
                    e.message +
                      ' at ' +
                      e.filename +
                      ':' +
                      e.lineno +
                      ':' +
                      e.colno
                  )
                } else {
                  window.errors.push(e.error.stack)
                }
                if (window.onNewError) window.onNewError()
              }
            } else {
              window.errors.push(
                'Problem loading ' + (e.target.src || e.target.href)
              )
              if (window.onNewError) window.onNewError()
            }
            window.onerror = null
          },
          true
        ) // true so that errors bubble up to window
        window.addEventListener(
          'unhandledrejection',
          function (e) {
            window.errors.push(
              e.reason && (e.reason.stack || e.reason.message || e.reason)
            )
            if (window.onNewError) window.onNewError()
          },
          false
        )
      }
      window.onerror = function (message, source, lineno, colno, error) {
        if (colno) {
          lineno += ':' + colno
        }
        if (error && error.stack) {
          window.errors.push(error.stack)
        } else {
          window.errors.push(message + ' at ' + source + ':' + lineno)
        }
        if (window.onNewError) window.onNewError()
      }
    </script>
  </head>
  <body>
    <textarea
      id="errors"
      readonly
      placeholder="I have not logged any errors."
    ></textarea>
    <div class="header">
      <h1>Project HTMLifier</h1>
      <h3><em>Convert a Scratch project to HTML</em></h3>
      <button
        class="htmlify"
        id="other-htmlify-btn"
        form="options"
        type="submit"
      >
        HTMLify
      </button>
    </div>
    <div class="mainarea">
      <p>
        This packages your Scratch project into a single HTML file that can run
        on its own in a web browser. The HTML file will be pretty big because it
        contains the entire Scratch engine (2.6 MB) and the costume and sound
        files used in the project.
      </p>
      <div class="notice info">
        <p>
          Note: The
          <strong
            ><a href="https://packager.turbowarp.org/"
              >TurboWarp Packager</a
            ></strong
          >
          has better performance and can produce .exe files. Refer to the
          <a href="#see-also">See also section</a> for more alternatives.
        </p>
      </div>
      <div id="root">
        <noscript>
          <div class="notice start-warning">
            <p>
              Please enable JavaScript. Converting projects can't be done with
              HTML and CSS alone.
            </p>
          </div>
        </noscript>
        <div class="notice start-warning hidden" id="js-enabled">
          <p>
            If you see this, you can check to see if there were
            <a href="#errors">any issues</a> loading the HTMLifier. Make sure
            you're using a modern browser.
          </p>
          <p class="hidden" id="no-nullish-coalescing">
            Your browser does not support modern JavaScript features; check to
            make sure
            <a
              href="https://caniuse.com/mdn-javascript_operators_nullish_coalescing"
              >your browser is modern</a
            >.
          </p>
        </div>
      </div>
      <p>
        If you want to view or edit the HTML file, you can use the specialized
        <a
          href="https://sheeptester.github.io/words-go-here/htmlifier/large-file-editor/"
          >Large File Editor</a
        >
        to hide the long lines that may hang or crash normal text editors.
      </p>
      <h2 id="updates">Update history</h2>
      <p>
        See the code and previous versions on
        <a href="https://github.com/SheepTester/htmlifier/">Github</a>.
      </p>
      <h3>
        2021-08-12 (<a
          href="https://github.com/SheepTester/htmlifier/releases/download/v1.0.2/htmlifier-offline.html"
          >download</a
        >)
      </h3>
      <ul>
        <li>Fixed connecting to cloud servers.</li>
      </ul>
      <h3>
        2021-08-09 (<a
          href="https://github.com/SheepTester/htmlifier/releases/download/v1.0.1/htmlifier-offline.html"
          >download</a
        >)
      </h3>
      <ul>
        <li>Fixed sprite dragging.</li>
      </ul>
      <h3>
        2021-08-08 (<a
          href="https://github.com/SheepTester/htmlifier/releases/download/v1.0.0/htmlifier-offline.html"
          >download</a
        >)
      </h3>
      <ul>
        <li>
          To support the use of the HTMLifier in
          <a href="https://nodejs.org/en/">Node</a> and
          <a href="https://deno.land/">Deno</a>, I rewrote the HTMLifier, so now
          it can be used programmatically (<a
            href="https://github.com/SheepTester/htmlifier/issues/27"
            >by request</a
          >). This might mean there could be many bugs.
        </li>
        <li>
          I also remade the options area in
          <a href="https://reactjs.org/">React</a> and reworded a few options in
          the process.
        </li>
        <li>
          The Scratch engine is stored in a separate file (<code>vm.js</code>)
          when you download as a ZIP, so you can make multiple HTMLified
          projects share the same Scratch engine file to avoid wasting disk
          space (by request).
        </li>
        <li>Downloading as a ZIP now works for <code>.sb2</code> files.</li>
        <li>
          <code>ctrl</code>/<code>⌘</code> + <code>F</code> now toggles
          fullscreen (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-141217533"
            >by request</a
          >).
        </li>
        <li>
          The loading image now appears <em>before</em> the background image (by
          request).
        </li>
        <li>
          You can detect whether the project has been HTMLified by doing
          <code>&lt;key (join [HTMLifier] []) pressed?&gt;</code> (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-129186942"
            >by request</a
          >).
        </li>
        <li>
          You can now add more than one unofficial extension (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-123224516"
            >by request</a
          >).
        </li>
        <li>
          You can add custom JavaScript (called "plugins" in
          <a href="https://sheeptester.github.io/scratch-gui/">E羊icques</a>) to
          the HTML. You can also upload JavaScript files instead of pasting URLs
          for both extensions and plugins. (Both
          <a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-142357006"
            >by request</a
          >.)
        </li>
        <li>
          Added an option to show a button that downloads the project with the
          current variable and list values stored (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-126598941"
            >by request</a
          >). This can be used to save your progress through a game.
        </li>
        <li>
          Added an option to show a button that lets you select a Scratch sprite
          to add to the project (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-120920668"
            >by request</a
          >). This can be used for some OS projects to add new apps, where each
          app is a sprite.
        </li>
        <li>List monitors now show item numbers.</li>
        <li>
          The loading bar now shows a percentage rather than a fraction (<a
            href="https://scratch.mit.edu/users/Sheep_maker/#comments-120295599"
            >by request</a
          >).
        </li>
        <li>
          Disabling sprite fencing has been separated from disabling the
          clone/list/etc. limits.
        </li>
      </ul>
      <details>
        <summary>Past updates</summary>
        <h3>
          2021-03-16 (<a
            href="https://github.com/SheepTester/htmlifier/releases/download/2021-03-16/htmlifier-offline.html"
            >download</a
          >)
        </h3>
        <ul>
          <li>
            New cloud behaviours:
            <ul>
              <li>
                <code>☁ url</code> contains the current URL of the web page.
              </li>
              <li>
                <code>☁ pasted</code> contains the last pasted text by the user.
              </li>
              <li>
                <code>☁ username</code>, when set, will change what the
                "username" block reports.
              </li>
            </ul>
          </li>
          <li>Fixed the background image not showing in full screen.</li>
          <li>Fixed the progress bar being shown under the loading image.</li>
        </ul>
        <h3>
          2021-02-07 (<a
            href="https://github.com/SheepTester/htmlifier/releases/download/2021-02-07/htmlifier-offline.html"
            >download</a
          >)
        </h3>
        <ul>
          <li>Save the options in the URL</li>
          <li>
            New customisation options:
            <ul>
              <li>Background image</li>
              <li>Cursor</li>
              <li>Favicon</li>
              <li>New loading bar design with customisable colours</li>
              <li>
                Loading screen image from a URL
                <ul>
                  <li>Option to stretch only the loading screen image</li>
                </ul>
              </li>
            </ul>
          </li>
          <li>
            Option to show start/stop buttons (equivalent to the green flag/stop
            sign)
          </li>
          <li>
            New special cloud behaviours:
            <ul>
              <li>Better support for <code>☁ eval</code> returning Promises</li>
              <li><code>☁ open link</code> opens a URL in a new tab.</li>
              <li><code>☁ redirect</code> redirects to a URL.</li>
              <li>
                <code>☁ set clipboard</code> tries to copy text to the
                clipboard.
              </li>
              <li>
                <code>☁ set server ip</code> changes the cloud server URL.
              </li>
            </ul>
          </li>
          <li>
            Ability to distinguish between left/right modifier keys using
            <code>&lt;key (join [code_ShiftLeft] []) pressed?>&gt;</code>, for
            example.
          </li>
          <li>
            Clicking on a variable slider no longer gives it focus, so keys will
            continue to work.
          </li>
          <li>A bookmarklet creator</li>
          <li>
            BREAKING: The mouse lock position now sets mouse x/y to the
            accumulative mouse position, which should be more reliable. This
            works best with the "Remove limits" option.
          </li>
          <li>
            Updated CSS by
            <a href="https://scratch.mit.edu/users/mrcringekidyt/"
              >Mr. Cringe Kid</a
            >
          </li>
          <li>Fixed the HTMLification log progress not resetting</li>
          <li>
            Also, the
            <a href="https://github.com/SheepTester/primitive-cloud-server"
              >primitive cloud server</a
            >
            has been updated.
          </li>
        </ul>
        <h3>2020-12-18</h3>
        <ul>
          <li>
            Specific mouse buttons can now be detected using
            <code>&lt;key (join [MouseN] []) pressed?&gt;</code>, where
            <code>N</code> can be 1 for left click, 2 for middle click, 3 for
            right click, and 0 for touch/pen.
          </li>
          <li>
            Fixed an issue where Scratch 2.0 projects with bitmap costumes
            wouldn't work.
          </li>
        </ul>
        <h3>
          2020-06-13 (<a
            href="https://github.com/SheepTester/htmlifier/releases/download/2020-06-13/htmlifier-offline.html"
            >download</a
          >)
        </h3>
        <ul>
          <li>More options for styling variable/list monitors</li>
          <li>Option to generate a .zip of files</li>
          <li>Option to preview the HTMLified project</li>
          <li>
            Readded the option for a progress counter despite lack of demand
          </li>
          <li>Warn if a file might be too large for JavaScript to HTMLify</li>
          <li>Fixed HTMLifying 2.0 projects</li>
        </ul>
        <h3>
          2020-06-01 (<a
            href="https://github.com/SheepTester/htmlifier/releases/download/2020-06-01/htmlifier-offline.html"
            >download</a
          >)
        </h3>
        <ul>
          <li>Option to remove clone/list length limits</li>
          <li>Option to hide the cursor</li>
          <li>
            Ability to distinguish between cloud variables for localStorage and
            the server (and run JavaScript using cloud variables)
          </li>
          <li>Option for rudimentary pointer lock</li>
          <li>Fixed mouse position and unresized lists not showing</li>
          <li>
            Default project changed to one of
            <a href="https://scratch.mit.edu/users/ScratchCat/">ScratchCat</a>'s
          </li>
          <li>
            Unfortunately, as part of these changes, I removed the option for a
            progress bar. If there's demand, I'll try to add it back.
          </li>
        </ul>
        <h3>2020-05-01</h3>
        <ul>
          <li>Support for custom extensions from a URL</li>
          <li>
            CSS by
            <a href="https://scratch.mit.edu/users/mrcringekidyt/"
              >Mr. Cringe Kid</a
            >
          </li>
        </ul>
        <h3>
          2020-03-29 (<a
            href="https://github.com/SheepTester/words-go-here/releases/download/htmlifier-2020-03-29/htmlifier-offline.html"
            >download</a
          >)
        </h3>
        <ul>
          <li>Fixed custom stage sizes</li>
        </ul>
        <h3>2020-03-27</h3>
        <ul>
          <li>Show an image such as a gif while loading</li>
          <li>Fixed dragging sprites simulating another green flag click</li>
        </ul>
        <h3>2020-01-06</h3>
        <ul>
          <li>An offline version of the HTMLifier</li>
        </ul>
        <h3>2019-12-25</h3>
        <ul>
          <li>
            An option to use a custom cloud server for cloud variables instead
            of saving to localStorage
          </li>
        </ul>
        <h3>2019-11-23</h3>
        <ul>
          <li>A fullscreen button</li>
          <li>An option to change monitor colours</li>
        </ul>
        <h3>2019-10-05</h3>
        <ul>
          <li>New ask box</li>
        </ul>
        <h3>2019-09-28</h3>
        <ul>
          <li>A status text that shows the assets loaded</li>
          <li>Support the video extension</li>
          <li>Support draggable sprites</li>
        </ul>
        <h3>2019-08-08</h3>
        <ul>
          <li>Removed "Scratch" from the name of this utility just in case</li>
        </ul>
        <h3>2019-07-27</h3>
        <ul>
          <li>Support 16:9 projects</li>
          <li>Simplify the number of modes for HTMLification</li>
        </ul>
        <h3>2019-07-13</h3>
        <ul>
          <li>Cloud variables store in localStorage</li>
        </ul>
        <h3>2019-06-29</h3>
        <ul>
          <li>Upload project file instead of using project ID</li>
          <li>Toggle compatibility and turbo mode</li>
        </ul>
        <h3>2019-03-31</h3>
        <ul>
          <li>Variable and list watchers</li>
        </ul>
        <h3>2019-02-09</h3>
        <ul>
          <li>Project start</li>
        </ul>
      </details>
      <h2 id="credits">Credits</h2>
      <p>
        Made by
        <a href="https://scratch.mit.edu/users/Sheep_maker/">Sheep_maker</a>,
        who used <a href="https://github.com/LLK/scratch-vm/">scratch-vm</a>,
        <a href="https://stuk.github.io/jszip/">JSZip</a>,
        <a href="https://deno.land/">Deno</a>,
        <a href="https://reactjs.org/">React</a>, and their dependencies for
        this project.
      </p>
      <p>
        CSS by
        <a href="https://scratch.mit.edu/users/mrcringekidyt/">Mr. Cringe Kid</a
        >.
      </p>
      <h2 id="see-also">See also</h2>
      <p>
        Depending on your use case, the HTMLifier may not be the best option for
        you. The HTMLifier prioritizes accuracy by using almost the same engine
        that vanilla Scratch uses, sacrificing speed and editability.
      </p>
      <p>
        If you want better performance, <em>compile</em> the project to
        JavaScript:
        <a href="https://phosphorus.github.io/">Phosphorus</a> (Scratch 2.0
        only), <a href="https://forkphorus.github.io/">Forkphorus</a>, and
        <a href="https://turbowarp.org/">TurboWarp</a>.
      </p>
      <p>
        If you want to learn JavaScript, convert the Scratch blocks to close
        equivalents in JavaScript using
        <a href="https://leopardjs.now.sh/">Leopard</a>.
      </p>
    </div>
    <script src="./index.bundle.min.js" charset="utf-8"></script>
    <script type="text/javascript">
      var errorsTextarea = document.getElementById('errors')
      if (!window.onNewError) {
        window.onNewError = function () {
          errorsTextarea.value =
            window.errors.length + ' errors(s)\n' + window.errors.join('\n')
        }
        window.onNewError()
      }
      try {
        eval('0 ?? 0')
      } catch (_) {
        var oldBrowserNotice = document.getElementById('no-nullish-coalescing')
        oldBrowserNotice.className = ''
      }
      var hasJs = document.getElementById('js-enabled')
      if (hasJs) {
        hasJs.classList.remove('hidden')
      }
    </script>
  </body>
</html>
